package Api;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

class Film{
    private String name;
    private int score;
    public Film(String name,int score) {
        this.name = name;
        this.score = score;
    }
    public int getScore() {
        return score;
    }
    public String toString() {
        return "Film{名字："+name+",观众评分："+score+"}";
    }
}
public class CollectionsSortDemo03 {
    public static void main(String[] args) {
        Film f1=new Film("哪吒",99 );
        Film f2=new Film("唐探",94);
        Film f3=new Film("封神",80);
        List<Film> list=new ArrayList<>();
        list.add(f1);
        list.add(f2);
        list.add(f3);
        Collections.sort(list, new Comparator<Film>() {
            @Override
            public int compare(Film o1, Film o2) {
                return o1.getScore()-o2.getScore();
            }
        });
        System.out.println(list);
    }
}
